//
// Copyright (c) 2009 All Right Reserved
//
// vl
//
// 2018-12-01
// Contains ...
using LargoCommon.Music;
using LargoPanels.Abstract;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace LargoPanels.Editor
{
///
/// Group Cell.
///
///
public class GroupCell : BaseCell
{
///
/// Initializes a new instance of the class.
///
/// The given master.
/// The given cell.
public GroupCell(EditorSpace givenMaster, ContentCell givenCell) : base(givenMaster) {
this.PenBrush = Brushes.DarkGray;
this.ContentBrush = Brushes.GhostWhite;
this.BarIndex = givenCell.BarIndex;
this.LineIndex = givenCell.LineIndex;
this.Point = givenCell.Point;
this.InnerCells = new List();
this.FirstCell = givenCell;
this.InnerCells.Add(givenCell);
}
#region Properties
///
/// Gets or sets the units.
///
///
/// The units.
///
public List InnerCells { get; set; }
///
/// Gets or sets the first unit.
///
///
/// The first unit.
///
public ContentCell FirstCell { get; set; }
///
/// Gets the first unit.
///
///
/// The first unit.
///
public MusicalElement FirstElement {
get {
return this.FirstCell.Element;
}
}
///
/// Gets or sets a value indicating whether this instance is single.
///
///
/// true if this instance is single; otherwise, false.
///
public bool IsSingle { get; set; }
///
/// Gets or sets the length.
///
///
/// The length.
///
public int Length { get; set; }
#endregion
#region Public methods
/// Gets or sets the formatted text.
/// The formatted text.
public override FormattedText FormattedText() {
//// sb.Append(this.RhythmicStructure.ElementSchema);
return this.FirstCell.FormattedText();
//// var ft = AbstractText.Singleton.FormatText(this.FirstElement.DisplayText, (int)this.Width - SeedSize.BasicMargin);
//// return ft;
}
/// Adds a musical element.
/// The given cell.
public void AddInnerCell(ContentCell givenCell) {
this.InnerCells.Add(givenCell);
this.Length = this.InnerCells.Count;
this.IsSingle = this.Length == 1;
this.Width = (SeedSize.CurrentWidth * this.Length) - SeedSize.BasicMargin;
//// this.Margin = new System.Windows.Thickness( CurrentWidth + (this.Point.BarNumber * CurrentWidth),
//// CurrentHeight + (this.Point.LineIndex * CurrentHeight), 0, 0);
this.Refresh();
}
///
/// Refreshes this instance.
///
public void Refresh() {
this.FirstElement.PrepareContent(this.FirstElement.ContentType);
//// this.ToolTip = this.FirstElement.ToolTip;
}
#endregion
#region Private methods
///
/// Sets the data.
///
/// The given data.
/// Returns value.
public bool SetData(IDataObject givenData) {
//// var space = this.Master as EditorSpace;
//// if (space != null) {
bool change = false;
foreach (var cell in this.InnerCells) {
if (cell.SetData(givenData)) {
change = true;
}
}
if (change) {
this.formattedText = null;
}
return true;
}
#endregion
}
}